<?php
    @session_start();
    if(!isset($_SESSION['islogined'])||$_SESSION['islogined']!=1)
        header("location:./Login.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <link href="app.css" rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

</head>
<body>
    <?php include 'header1.php'; ?>
    <div class="container home1-container">
        <div class="col-xs-3 col-md-3 col-lg-3">
            <div class="list-group">
                <?php include 'ListManage.php';?>
            </div>
        </div>
        <div id="show" class="col-xs-9 col-md-9 col-lg-9">
            <?php include'TaskRequest.php'; ?>
        </div>
    </div>
    <!--模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    
</div>
<script src="jquery-form.js"></script>
<script src="jquery-3.0.0.min.js"></script>
<script src="bootstrap.min.js"></script>
<script>
   $(function(){
        boxJump();
        PageContral();
        $(".list-group-item").click(function(){
            $(".list-group-item").removeClass("active");
            var str=$(this).data('id');           
            var str1="."+str;
            $(this).addClass("active");
            $(str1).toggle();
            $.get("TaskRequest.php?id=l_"+str,null,function(data){
                $('#show').html(data);
       	        boxJump();
                PageContral();
            })
        });

   });
function boxJump(){
        $(".jm-box").click(function(){
            var str=$(this).data('id');
            $.get("TaskRequest.php?id="+str,null,function(data){
                $('#myModal').html(data);                
                $('#myModal').modal();
                formdispose();
            })
        });
}
function PageContral(){
    $(".pageContral").click(function(){
            var str=$(this).data('id');
            $.get("TaskRequest.php?id=l_q&pageNow="+str,null,function(data){
                $('#show').html(data);
                boxJump();
                PageContral();
            })
        });
}
function formdispose(){
    $("#update_btn").click(function(){
           var f_type=$("#type").val();
           var f_taskID=$("#taskID").val();
           if($("#wlus").length>0){
               var unitnum=$("#unitnum").val();
               var f_wlus=$("#wlus").val();
           }
           else{
               unitnum=null;
               f_wlus=null;
           }
           var f_notes=$("#notes").val();
           $.post("infor_change.php",{
               type:f_type,
               taskID:f_taskID,
               wlus:f_wlus,
               unitnum:unitnum,
               notes:f_notes
           },function (data){
               $('.success-coin').remove();
               $('#'+f_taskID).html(data);
               boxJump();
           })
       });
    $('#finish_btn').click(function(){
        var f_listID;
        $(".list-group-item").each(function(){
            if($(this).hasClass('active')){
                f_listID=$(this).data('id');
                return true;
            }
        });
        var f_type=$("#type").val();
        var f_taskID=$("#taskID").val();
        var f_current=$("#current").val();
         $.post("infor_change.php",{
               listID:f_listID,
               type:f_type,
               taskID:f_taskID,
               current:f_current
           },function (data){
               if(f_listID=='q'){
                   $('.success-coin').remove();
                   $('#'+f_taskID).html(data);
               }
               else{
                   $('.success-coin').remove();
                   $('#show').html(data);
               }
               boxJump();
           })
    });
}
/*function showBox(str){
    console.log('OK1');
    if (window.XMLHttpRequest){
         // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else{
        // IE6, IE5 浏览器执行代码 
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
        var url="TaskRequest.php";
        url=url+"?id="+str;        
        xmlhttp.open("GET",url,true);
        xmlhttp.onreadystatechange=myfunc;
        xmlhttp.send(null);
}
function myfunc(){
        console.log("aasf");
        if(xmlhttp.readyState==4 && xmlhttp.status==200){
             console.log(xmlhttp.responseText);
             document.getElementById('Box').innerHTML=xmlhttp.responseText;
             $('#myModal').modal();
         }
    }*/
/*    var xmlhttp;
    xmlHttp=GetXmlHttpObject();
    if(xmlHttp==null){
        alert("Browser does not support HTTP Request");
        return;
    }
    var url="TaskRequest.php";
    url=url+"?id="+str;
    xmlHttp.onreadystatechange=stateChanged();
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function stateChanged(){
    if(xmlHttp.readyState==4||xmlHttp.status==200){
        document.getElementById("Box").innerHTML=xmlHttp.responseText;        
    }
}
function GetXmlHttpObject(){
    var xmlHttp=null;
    try{
        xmlHttp=new XMLHttpRequest();
    }
    catch(e){
        try{
            xmlHttp=new ActiveXObject("Msxm12.XMLHTTP");
        }catch(e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}*/
</script>
</body>
</html>